package process;

import fabrik.Project;
/**This class represents the Manager, the main.
 * Here are all commands invoked to calculate the faz,fez,saz,sez and puffers values.
 * @author Janet
 *@version 1.0
 */
public class Manager {
	/**attribute project.*/
	private Project project;

	/**
	 * First constructor of this method,creates a new project with the input
	 * file.
	 * 
	 * @param inputFilePath , file to read in
	 */
	public Manager(String inputFilePath) {
		project = new Project(inputFilePath);
	}

	/**
	 * Second constructor,creates a new project with input file,a start and end
	 * process name, this gets used.
	 * 
	 * @param inputFilePath     ,file to read in
	 * @param startProcessName   ,name to set the first values later on
	 * @param endProcessName ,name to set the last later on
	 */
	public Manager(String inputFilePath, String startProcessName,
			String endProcessName) {
		project = new Project(inputFilePath, startProcessName, endProcessName);
	}
	/**
	 * Checks args.
	 * @param args the argument
	 */
	public static void main(String[] args) {
		Manager manager;
		if (args.length > 0) {
			manager = new Manager(args[0]);
		} else {
			manager = new Manager("resources/testdaten/Test1");
		}
		manager.process();
	}

	/**
	 * Invokes the command to initialize the project.
	 * 
	 */
	public void process() {
		project.sortRelationListByPrecessor();

		// finds double successor if they exist
		project.forwardCalculation();
		// finds double predecessors if they exist
		project.backwardCalculation();
		// calculates the complete puffer
		project.setTotalPuffer();
		// calculates the free puffer
		project.calculateFreePuffer();
		// prints out the project
		project.print();
	}

	/**getter of project.
	 * @return project of the file*/
	public Project getProject() {
		return project;
	}
}
